package cn.wolfcode.wolfcodemall.util;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Map;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println(
                "请求方法: " + request.getMethod() + "\n" +
                "请求路径: " + request.getRequestURL()
        );

        System.out.print("请求参数: ");
        Map<String, String[]> parameterMap = request.getParameterMap();
        parameterMap.forEach((k, v) -> System.out.println(k + ":" + Arrays.toString(v)));
        return true;
    }
}
